package cn.yhz.pethome.dept.service.impl;

import cn.yhz.pethome.base.util.ResultBean;
import cn.yhz.pethome.dept.Query.DepartmentQuery;
import cn.yhz.pethome.dept.domain.Department;
import cn.yhz.pethome.dept.mapper.IDepartmentMapper;
import cn.yhz.pethome.dept.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class DepartmentServiceImpl implements IDepartmentService {
    @Autowired
    private IDepartmentMapper departmentMapper;
    @Override
    public ResultBean<Department> query(DepartmentQuery query) {
        ResultBean<Department> resultBean = new ResultBean<>();
        resultBean.setTotal(departmentMapper.count(query));
        resultBean.setPageList(departmentMapper.selectAll(query));
        return resultBean;
    }

    @Override
    public Department selectById(Long id) {
        return departmentMapper.selectById(id);
    }

    @Override
    public void insert(Department department) {
        departmentMapper.insert(department);
    }

    @Override
    public void update(Department department) {
        departmentMapper.update(department);
    }

    @Override
    public void delete(Long id) {
        departmentMapper.delete(id);
    }
}
